/*
ID: icerupt1
PROG: game1
LANG: C++11
*/

/* solution
 *
 * simple dp maybe.
 *
*/
#include <fstream>
#include <algorithm>
#include <iostream>

std::ifstream fin {"game1.in" };
std::ofstream fout{"game1.out"};

int const maxn = 202;
int f[maxn][maxn];
bool get[maxn][maxn];
int da[maxn];
int n;

bool calc(int l, int r) //left: true  right: false
{
	if (f[l][r]) return get[l][r];
	if (l+1 == r) {
		f[l][r] = da[l];
		return get[l][r];
	}
	if (l+2 == r) {
		f[l][r] = std::max(da[l], da[l+1]);
		get[l][r] = true;
		if (da[l+1] > da[l]) get[l][r] = false;
		return get[l][r];
	}
	//chose left
	f[l][r] = da[l];
	if (calc(l+1, r)) {
		calc(l+2, r);
		f[l][r] += f[l+2][r];
	} else {
		calc(l+1, r-1);
		f[l][r] += f[l+1][r-1];
	}

	//chose right
	int tmp = da[r-1];
	if (calc(l, r-1)) {
		calc(l+1, r-1);
		tmp += f[l+1][r-1];
	} else {
		calc(l, r-2);
		tmp += f[l][r-2];
	}
	if (f[l][r] > tmp)
		return get[l][r] = true;
	else {
		f[l][r] = tmp;
		return get[l][r] = false;
	}
}

int main()
{
	fin >> n;
	for (int i = 0; i < n; i++)
		fin >> da[i];
	calc(0, n);
	calc(0, n-1); calc(1, n);

	std::cout << f[0][n] << ' ' << std::min(f[0][n-1], f[1][n]) << '\n';
	fout << f[0][n] << ' ' << std::min(f[0][n-1], f[1][n]) << '\n';
}

